package com.btpj.login_json.modell;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class RespBean<T> {

    private int status;
    private String msg;
    private T data;

    public static <T> RespBean<T> success(T data, String msg) {
        RespBean<T> respBean = new RespBean<>();
        respBean.status = 0;
        respBean.msg = msg;
        respBean.data = data;
        return respBean;
    }

    public static <T> RespBean<T> success(T data) {
        return RespBean.success(data, "请求成功");
    }

    public static RespBean<Void> error(String msg) {
        RespBean<Void> respBean = new RespBean<>();
        respBean.status = 1;
        respBean.msg = msg;
        return respBean;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
